package com.travelsky.login.api;

import java.io.Serializable;
import java.util.StringJoiner;

/**
 * Resource响应基类
 */
public class BaseResponse implements Serializable {

  private static final long serialVersionUID = 1L;

  private Error error;

  public BaseResponse() {
  }

  public BaseResponse(Error error) {
    this.error = error;
  }

  /**
   * Gets the value of error.
   *
   * @return the value of error
   */
  public Error getError() {
    return error;
  }

  /**
   * Sets the error.
   *
   * @param error error
   * @return this
   */
  public BaseResponse setError(Error error) {
    this.error = error;
    return this;
  }

  @Override
  public String toString() {
    return new StringJoiner(", ", BaseResponse.class.getSimpleName() + "[", "]")
        .add("error=" + error)
        .toString();
  }

  public static class Error implements Serializable {

    private String code = "";
    private String msg = "";

    public Error() {
    }

    public Error(String code, String msg) {
      this.code = code;
      this.msg = msg;
    }

    /**
     * Gets the value of code.
     *
     * @return the value of code
     */
    public String getCode() {
      return code;
    }

    /**
     * Sets the code.
     *
     * @param code code
     * @return this
     */
    public Error setCode(String code) {
      this.code = code;
      return this;
    }

    /**
     * Gets the value of msg.
     *
     * @return the value of msg
     */
    public String getMsg() {
      return msg;
    }

    /**
     * Sets the msg.
     *
     * @param msg msg
     * @return this
     */
    public Error setMsg(String msg) {
      this.msg = msg;
      return this;
    }

    @Override
    public String toString() {
      return new StringJoiner(", ", Error.class.getSimpleName() + "[", "]")
          .add("code='" + code + "'")
          .add("msg='" + msg + "'")
          .toString();
    }
  }
}
